package com.example.mapping.sevice;

import com.example.mapping.domain.ColumnMetadata;
import com.example.mapping.domain.TableMetadata;
import com.example.mapping.mapper.TableMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 表service类
 *
 * @author baoyoujia
 */
@Service
public class TableService {

    private final TableMapper tableMapper;

    public TableService(TableMapper tableMapper) {
        this.tableMapper = tableMapper;
    }

    /**
     * 获取所有的表
     *
     * @return 表信息
     */
    public List<TableMetadata> getTableMetadata() {
        return tableMapper.tableList();
    }

    /**
     * 获取表的所有列
     *
     * @param tableName 表名
     * @return 列信息
     */
    public List<ColumnMetadata> getColumnMetadata(String tableName) {
        return tableMapper.tableColumnList(tableName);
    }
}
